package ru.picman.util;

/**
 * Contains some basic math functions.
 * 
 * @author Matthijs
 */
public class EasyMath
{   
	
	/**
	 * Returns min if i < min, max if i > max and i otherwise.
	 * 
	 * @param i The value
	 * @param min The minimum value
	 * @param max The maximum value
	 * @return The value, clamped.
	 */
	public static int clamp(int i, int min, int max) {
		return (i < min ? min : (i > max ? max : i));
	}
	
	/**
	 * Checks if the specified value is between the two other values.
	 * 
	 * @param a The value
	 * @param min The minimum value
	 * @param max The maximum value
	 * @return true if it is between, false otherwise
	 */
	public static boolean isBetween(int a, int min, int max) {
		return a > min && a < max;
	}
	
	/**
	 * Checks if the specified value is between or equal to the min/max.
	 * 
	 * @param a The value
	 * @param min The minimum value
	 * @param max The maximum value
	 * @return true if it is between, false otherwise
	 */
	public static boolean isBetweenIncl(float a, float min, float max) {
		return a >= min && a <= max;
	}
	
}
